package kd.bos.demo_plugin.baseinfo;

import java.util.List;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.metadata.clr.DataEntityPropertyCollection;
import kd.bos.entity.MainEntityType;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.entity.property.ComboProp;
import kd.epm.eb.formplugin.AbstractBasePlugin;

public class xialaliebiao extends AbstractBasePlugin {
    private final static String KEY_STRING = "comt_combofield";

    @Override
    public void propertyChanged(PropertyChangedArgs e) {

        String fieldkey = e.getProperty().getName();
        //this.getView().showSuccessNotification(fieldkey);
        //this.getView().showSuccessNotification("02");

        if (KEY_STRING.equals(fieldkey)) {
            // 获取选中下拉值
            String value = (String) getModel().getValue("comt_combofield");
            // 获取下拉列表字段
            ComboProp comboProp = (ComboProp) getModel().getProperty("comt_combofield");
            // 通过下拉值获取下拉标题
            String displayName = comboProp.getItemByName(value);
            //this.getView().showSuccessNotification(displayName);
            if(displayName.equals("学生")){
                this.getModel().setValue("comt_borrow_books",20);
                this.getModel().setValue("comt_borow_days",30);
            }else if(displayName.equals("教师")){
                this.getModel().setValue("comt_borrow_books",50);
                this.getModel().setValue("comt_borow_days",60);
            }
        }
    }

}
